<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no" />
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/icon.css">
<link rel="stylesheet" href="../static/css/style-app.css" />
<script src="../static/jquery/jquery-1.12.4.js"></script>
<script src="../static/easyui/jquery.easyui.min.js"></script>
<script src="../static/easyui/locale/easyui-lang-zh_CN.js"></script>
<title>技术论坛</title>
</head>

<body>
	<div class="top-part">
		<div class="header">
			<div class="return">
				<a href="javascript:history.go(-1);"></a>
			</div>
			<div class="header-title">发表新帖</div>
		</div>
	</div>
	<div class="new-form">
		<div>
			<form id="ff" method="post">
				<table>
					<tr>
						<td style="width: 80px;">标题：</td>
						<td>
							<input class="easyui-textbox" id="title1" name="title1"
								style="width: 100%;" />
						</td>
					</tr>
					<tr>
						<td style="width: 80px;">内容：</td>
						<td >
							<input class="easyui-textbox" data-options="multiline:true" id="content" name="content"
								style="width: 100%; height: 100px;" />
						</td>
					</tr>
					<tr>
						<td style="width: 80px;">上传图片：</td>
						<td>
							<input class="easyui-filebox"
								data-options="prompt:'添加文件', buttonText:'选择附件',multiple:true,accept:'image/*'" id="images"
								name="images" style="width: 100%;" />
						</td>
					</tr>
				</table>
			</form>
			<div class="text-center" id="div1">
				<a href="#" class="d-btn btn-blue" onclick="savePro()">保存</a>
			</div>
		</div>
	</div>
</body>
<script>
	function savePro() {
		var formData = new FormData();
		formData.append("title", $("#title1").textbox('getValue'));
		formData.append("content", $("#content").textbox('getValue'));
		var images = document.getElementById("filebox_file_id_1").files;
		for(var i = 0;i < images.length;i++){
			formData.append('images', images[i]);
		}
		$.ajax({
			type : 'POST',
			url : "../forumPostSave.do",
			cache : false,
			data : formData,
			processData : false,
			contentType : false,
			success : function(data) {
				if (data.success){
					$.messager.alert('发表新帖', '发表新帖成功', 'success');
				}else{
					$.messager.alert('发表新帖', '发表新帖失败', 'error');
				}
				window.setInterval("window.location.href=document.referrer", 2000);
			},
			dataType : "json"
		});
	}
</script>
</html>